package com.njrsrc.android.library.vpi;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.util.DisplayMetrics;

import com.flurry.android.FlurryAgent;
import com.njrsrc.R;
import com.njrsrc.android.fragment.MenuFragment;
import com.njrsrc.android.library.sm.SlidingFragmentActivity;
import com.njrsrc.android.library.sm.SlidingMenu;

public abstract class BaseSampleActivity extends SlidingFragmentActivity {
	protected MenuFragment mFrag;
	protected static SharedPreferences preferences;
	protected int width;
	protected int height;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		preferences = getSharedPreferences("njrsrc", MODE_PRIVATE);
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		width = dm.widthPixels;
		height = dm.heightPixels;

		// set the Behind View
		setBehindContentView(R.layout.slidemenu_frame);
		FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
		mFrag = new MenuFragment();
		t.replace(R.id.menu_frame, mFrag);
		t.commit();

		// customize the SlidingMenu
		SlidingMenu sm = getSlidingMenu();
		sm.setShadowWidthRes(R.dimen.shadow_width);
		sm.setShadowDrawable(R.drawable.shadow);
		sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		sm.setFadeDegree(0.35f);
		sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		sm.setBehindWidth((int) (0.5 * width));
		sm.setBehindScrollScale(0.1f);
		
	}
	
	@Override
    protected void onStart() {
        super.onStart();
        FlurryAgent.onStartSession(this, "QMXRD2F95Q6YGS4Z9MZ9");
    }

    @Override
    protected void onStop() {
        super.onStop();
        FlurryAgent.onEndSession(this);
    }
}
